<template>
  <div id="ShopClass" class="ShopClass">
    <h1>
      品类管理
      <el-button type="primary" class="btn el-icon-plus">添加品类</el-button>
    </h1>
    <el-table :data="classlist" border style="width: 100%">
      <el-table-column prop="id" label="品类ID" width="180"></el-table-column>
      <el-table-column prop="name" label="品类名称" width="300"></el-table-column>
      <el-table-column label="操作">
        <span class="gai">修改名称</span>
        <span class="gai">查看其子类品</span>
      </el-table-column>
    </el-table>
    <paging :total="total" @sorter="handleCurrentChange"></paging>
  </div>
</template>

<script>
import { Class } from "@/request/http";
import { Classpage } from "@/request/http";
// 一如公共的子组件分页组件
import paging from "@/pages/home/components/paging";

export default {
  props: {},
  // name: "ShopClass",
  data() {
    return {
      classlist: [],
      total: 5,
    };
  },
  created() {},
  computed: {},
  components: {
    paging,
  },
  methods: {
    // 方法集合
    handleCurrentChange(val) {
      Classpage(val).then((data) => {
        // console.log(data.data);
        this.classlist = data.data.data;
        console.log(this.classlist);
      });
    },
  },
  mounted() {
    // 页面进入时加载内容
    Class.then((data) => {
      // console.log(data);
      this.classlist = data.data.data;
      this.total = data.data.data.length;
      // console.log(this.total)
      // console.log(this.classlist);
    });
  },
  watch: {},
};
</script>
<style scoped lang="scss">
.ShopClass {
  .gai {
    color: rgb(144, 192, 219);
    margin-left: 10px;
  }
}

h1 {
  font-size: 60px;
  padding: 40px;
  display: flex;
}
.btn {
  font-size: 20px;
  margin-left: 900px;
  border: 1px solid #ffffff;
}
</style>